package io.gitee.tuo_tuo.jfinaldevassistance.interceptors;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.jfinal.log.Log;
import io.gitee.tuo_tuo.jfinaldevassistance.controller.ControllerSupport;

/**
 * 类名称：ubap
 * 描述: 控制器增强
 * 版权: Copyright (c) 2018
 * 公司:
 * 作者: tuotuo
 * 版本: 1.0
 * 创建日期: 2018/5/8
 * 创建时间: 18:37
 */
public class ControllerEnhance implements Interceptor {
	private static final Log log = Log.getLog(ControllerEnhance.class);

	@Override
	public void intercept(Invocation inv) {
		try {
			Controller controller = inv.getController();
			if(controller instanceof ControllerSupport){
				ControllerSupport controllerSupport = (ControllerSupport) controller;
				controllerSupport.init();
			}
		}catch (Exception e){
			log.error(e.toString());
		}
		inv.invoke();
	}
}
